import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gourmet/color/hex.dart';
import 'package:gourmet/ui/triangle.dart';
import 'package:gourmet/utils/colors.dart';
import 'package:gourmet/utils/styles.dart';

class AllEvaluteController extends GetxController {
  List<String> imgs = [
    'https://img1.baidu.com/it/u=4008250404,3759017256&fm=253&fmt=auto&app=138&f=JPEG?w=749&h=500',
    'https://img1.baidu.com/it/u=1630251570,3684454578&fm=253&fmt=auto&app=138&f=JPEG?w=508&h=359',
    'https://img1.baidu.com/it/u=797357420,4142825589&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  ];
}

class AllEvaluteView extends GetView<AllEvaluteController> {
  const AllEvaluteView({super.key});

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.only(top: 10, left: mid, right: mid),
            child: Column(
              children: [
                Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10),
                  ),
                  padding: const EdgeInsets.all(15),
                  child: Column(
                    children: [
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Image.network(
                            'https://img2.baidu.com/it/u=3108974623,3149747199&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
                            width: 40,
                            height: 40,
                            fit: BoxFit.fill,
                          ),
                          Expanded(
                            child: Padding(
                              padding: const EdgeInsets.only(left: 10),
                              child: Stack(
                                children: [
                                  Column(
                                    children: [
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Text(
                                            '华莱士-凤凰广场2店',
                                            style: StylesUtils.customTextStyle(
                                              fontWeight: FontWeight.w700,
                                              color: ColorsUtils.color0000,
                                            ),
                                          ),
                                          PopupMenuButton<int>(
                                            itemBuilder: (_) {
                                              return [
                                                PopupMenuItem(
                                                  value: 1,
                                                  child: Stack(
                                                    children: [
                                                      Container(
                                                        constraints:
                                                            const BoxConstraints
                                                                .expand(
                                                                width: 90,
                                                                height: 40),
                                                        alignment:
                                                            Alignment.center,
                                                        child: Text(
                                                          '我要匿名',
                                                          style: StylesUtils
                                                              .customTextStyle(
                                                            fontSize:
                                                                StylesUtils
                                                                    .fontSize15,
                                                          ),
                                                        ),
                                                      ),
                                                      Transform.translate(
                                                        offset: const Offset(
                                                            30, -22),
                                                        child: Container(
                                                          height: 10,
                                                          color: Colors
                                                              .transparent,
                                                          alignment:
                                                              Alignment.center,
                                                          child: CustomPaint(
                                                            size: const Size(
                                                                15, 10),
                                                            painter:
                                                                TrianglePainter(
                                                              isDown: false,
                                                              color: HexColor(
                                                                      ColorsUtils
                                                                          .color3333)
                                                                  .withOpacity(
                                                                      0.898039),
                                                            ),
                                                          ),
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                                PopupMenuItem(
                                                  value: 2,
                                                  child: Container(
                                                    constraints:
                                                        const BoxConstraints
                                                            .expand(
                                                            width: 90,
                                                            height: 40),
                                                    alignment: Alignment.center,
                                                    child: Text(
                                                      '删除评价',
                                                      style: StylesUtils
                                                          .customTextStyle(
                                                        fontSize: StylesUtils
                                                            .fontSize15,
                                                      ),
                                                    ),
                                                  ),
                                                )
                                              ];
                                            },
                                            elevation: 0,
                                            padding: EdgeInsets.zero,
                                            color:
                                                HexColor(ColorsUtils.color3333)
                                                    .withOpacity(0.898039),
                                            splashRadius: 5,
                                            position: PopupMenuPosition.under,
                                            constraints: const BoxConstraints(
                                                maxWidth: 90),
                                            offset: const Offset(10, 10),
                                            child: Icon(
                                              CupertinoIcons.ellipsis,
                                              size: 15,
                                              color: HexColor(
                                                ColorsUtils.color0000,
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                      Container(
                                        margin: const EdgeInsets.only(top: 5),
                                        alignment: Alignment.centerLeft,
                                        child: Text(
                                          '2097-09-25',
                                          style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.color9999,
                                            fontSize: StylesUtils.fontSize12,
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Positioned(
                                    top: 10,
                                    right: 70,
                                    child: Container(
                                      constraints: const BoxConstraints.expand(
                                          width: 42, height: 18),
                                      alignment: Alignment.center,
                                      decoration: BoxDecoration(
                                        border: Border.all(
                                          color:
                                              HexColor(ColorsUtils.colorCc00),
                                        ),
                                        borderRadius: BorderRadius.circular(2),
                                      ),
                                      child: Text(
                                        '审核中',
                                        style: StylesUtils.customTextStyle(
                                          color: ColorsUtils.colorCc00,
                                          fontSize: StylesUtils.fontSize12,
                                        ),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ],
                      ),
                      Container(
                        margin: const EdgeInsets.symmetric(vertical: 12),
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: 20,
                          alignment: WrapAlignment.start,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          children: [
                            Text.rich(
                              TextSpan(
                                children: [
                                  TextSpan(
                                    text: '商家：',
                                    style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color7979,
                                      fontSize: StylesUtils.fontSize13,
                                    ),
                                  ),
                                  for (var i = 0; i < 3; i++)
                                    WidgetSpan(
                                        child: Icon(
                                          CupertinoIcons.star_fill,
                                          size: 15,
                                          color:
                                              HexColor(ColorsUtils.colorFe46),
                                        ),
                                        alignment: PlaceholderAlignment.middle),
                                  WidgetSpan(
                                      child: Icon(
                                        CupertinoIcons.star_fill,
                                        size: 15,
                                        color: HexColor(ColorsUtils.colorCccc),
                                      ),
                                      alignment: PlaceholderAlignment.middle),
                                ],
                              ),
                            ),
                            Text(
                              '味道4星　包装5星',
                              style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color7979,
                                fontSize: StylesUtils.fontSize13,
                              ),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        alignment: Alignment.centerLeft,
                        margin: const EdgeInsets.only(bottom: 15),
                        child: Text(
                          '一如既往的不错，比较清淡，适合南方人口味，我堂食买的一样。',
                          style: StylesUtils.customTextStyle(
                              fontSize: StylesUtils.fontSize15,
                              color: ColorsUtils.color0000,
                              lineHeight: 1.4),
                        ),
                      ),
                      Align(
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: 6,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          alignment: WrapAlignment.start,
                          children: controller.imgs
                              .map((url) => Image.network(
                                    url,
                                    width: 100,
                                    height: 100,
                                    fit: BoxFit.fill,
                                  ))
                              .toList(),
                        ),
                      )
                    ],
                  ),
                ),
                Container(
                  padding: const EdgeInsets.only(
                      top: 20, left: 15, right: 10, bottom: 15),
                  child: Column(
                    children: [
                      Container(
                        alignment: Alignment.centerLeft,
                        child: Text.rich(
                          TextSpan(
                            children: [
                              TextSpan(
                                text: '配送：',
                                style: StylesUtils.customTextStyle(
                                  color: ColorsUtils.color7979,
                                  fontSize: StylesUtils.fontSize13,
                                ),
                              ),
                              for (var i = 0; i < 3; i++)
                                WidgetSpan(
                                    child: Icon(
                                      CupertinoIcons.star_fill,
                                      size: 15,
                                      color: HexColor(ColorsUtils.colorFe46),
                                    ),
                                    alignment: PlaceholderAlignment.middle),
                              WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.star_fill,
                                    size: 15,
                                    color: HexColor(ColorsUtils.colorCccc),
                                  ),
                                  alignment: PlaceholderAlignment.middle),
                            ],
                          ),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(top: 10),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          '有点慢了，但是大风大雨的，送餐速度还能准时，辛苦外卖小哥哥了。',
                          style: StylesUtils.customTextStyle(
                            color: ColorsUtils.color0000,
                            fontSize: StylesUtils.fontSize13,
                            lineHeight: 1.5,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

double get mid {
  return (Get.width - 345) / 2;
}

class PictureEvaluteController extends GetxController {
  List<String> imgs = [
    'https://img1.baidu.com/it/u=4008250404,3759017256&fm=253&fmt=auto&app=138&f=JPEG?w=749&h=500',
    'https://img1.baidu.com/it/u=1630251570,3684454578&fm=253&fmt=auto&app=138&f=JPEG?w=508&h=359',
    'https://img1.baidu.com/it/u=797357420,4142825589&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
  ];
}

class PictureEvaluteView extends GetView<PictureEvaluteController> {
  const PictureEvaluteView({super.key});

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.only(top: 10, left: mid, right: mid),
            child: Column(
              children: [
                Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10),
                  ),
                  padding: const EdgeInsets.all(15),
                  child: Column(
                    children: [
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Image.network(
                            'https://img2.baidu.com/it/u=3108974623,3149747199&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375',
                            width: 40,
                            height: 40,
                            fit: BoxFit.fill,
                          ),
                          Expanded(
                            child: Padding(
                              padding: const EdgeInsets.only(left: 10),
                              child: Stack(
                                children: [
                                  Column(
                                    children: [
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Text(
                                            '华莱士-凤凰广场2店',
                                            style: StylesUtils.customTextStyle(
                                              fontWeight: FontWeight.w700,
                                              color: ColorsUtils.color0000,
                                            ),
                                          ),
                                          PopupMenuButton<int>(
                                            itemBuilder: (_) {
                                              return [
                                                PopupMenuItem(
                                                  value: 1,
                                                  child: Stack(
                                                    children: [
                                                      Container(
                                                        constraints:
                                                            const BoxConstraints
                                                                .expand(
                                                                width: 90,
                                                                height: 40),
                                                        alignment:
                                                            Alignment.center,
                                                        child: Text(
                                                          '我要匿名',
                                                          style: StylesUtils
                                                              .customTextStyle(
                                                            fontSize:
                                                                StylesUtils
                                                                    .fontSize15,
                                                          ),
                                                        ),
                                                      ),
                                                      Transform.translate(
                                                        offset: const Offset(
                                                            30, -22),
                                                        child: Container(
                                                          height: 10,
                                                          color: Colors
                                                              .transparent,
                                                          alignment:
                                                              Alignment.center,
                                                          child: CustomPaint(
                                                            size: const Size(
                                                                15, 10),
                                                            painter:
                                                                TrianglePainter(
                                                              isDown: false,
                                                              color: HexColor(
                                                                      ColorsUtils
                                                                          .color3333)
                                                                  .withOpacity(
                                                                      0.898039),
                                                            ),
                                                          ),
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                                PopupMenuItem(
                                                  value: 2,
                                                  child: Container(
                                                    constraints:
                                                        const BoxConstraints
                                                            .expand(
                                                            width: 90,
                                                            height: 40),
                                                    alignment: Alignment.center,
                                                    child: Text(
                                                      '删除评价',
                                                      style: StylesUtils
                                                          .customTextStyle(
                                                        fontSize: StylesUtils
                                                            .fontSize15,
                                                      ),
                                                    ),
                                                  ),
                                                )
                                              ];
                                            },
                                            elevation: 0,
                                            padding: EdgeInsets.zero,
                                            color:
                                                HexColor(ColorsUtils.color3333)
                                                    .withOpacity(0.898039),
                                            splashRadius: 5,
                                            position: PopupMenuPosition.under,
                                            constraints: const BoxConstraints(
                                                maxWidth: 90),
                                            offset: const Offset(10, 10),
                                            child: Icon(
                                              CupertinoIcons.ellipsis,
                                              size: 15,
                                              color: HexColor(
                                                ColorsUtils.color0000,
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                      Container(
                                        margin: const EdgeInsets.only(top: 5),
                                        alignment: Alignment.centerLeft,
                                        child: Text(
                                          '2097-09-25',
                                          style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.color9999,
                                            fontSize: StylesUtils.fontSize12,
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Positioned(
                                    top: 10,
                                    right: 70,
                                    child: Container(
                                      constraints: const BoxConstraints.expand(
                                          width: 42, height: 18),
                                      alignment: Alignment.center,
                                      decoration: BoxDecoration(
                                        border: Border.all(
                                          color:
                                              HexColor(ColorsUtils.colorCc00),
                                        ),
                                        borderRadius: BorderRadius.circular(2),
                                      ),
                                      child: Text(
                                        '审核中',
                                        style: StylesUtils.customTextStyle(
                                          color: ColorsUtils.colorCc00,
                                          fontSize: StylesUtils.fontSize12,
                                        ),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ],
                      ),
                      Container(
                        margin: const EdgeInsets.symmetric(vertical: 12),
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: 20,
                          alignment: WrapAlignment.start,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          children: [
                            Text.rich(
                              TextSpan(
                                children: [
                                  TextSpan(
                                    text: '商家：',
                                    style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color7979,
                                      fontSize: StylesUtils.fontSize13,
                                    ),
                                  ),
                                  for (var i = 0; i < 3; i++)
                                    WidgetSpan(
                                        child: Icon(
                                          CupertinoIcons.star_fill,
                                          size: 15,
                                          color:
                                              HexColor(ColorsUtils.colorFe46),
                                        ),
                                        alignment: PlaceholderAlignment.middle),
                                  WidgetSpan(
                                      child: Icon(
                                        CupertinoIcons.star_fill,
                                        size: 15,
                                        color: HexColor(ColorsUtils.colorCccc),
                                      ),
                                      alignment: PlaceholderAlignment.middle),
                                ],
                              ),
                            ),
                            Text(
                              '味道4星　包装5星',
                              style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color7979,
                                fontSize: StylesUtils.fontSize13,
                              ),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        alignment: Alignment.centerLeft,
                        margin: const EdgeInsets.only(bottom: 15),
                        child: Text(
                          '一如既往的不错，比较清淡，适合南方人口味，我堂食买的一样。',
                          style: StylesUtils.customTextStyle(
                              fontSize: StylesUtils.fontSize15,
                              color: ColorsUtils.color0000,
                              lineHeight: 1.4),
                        ),
                      ),
                      Align(
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: 6,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          alignment: WrapAlignment.start,
                          children: controller.imgs
                              .map((url) => Image.network(
                                    url,
                                    width: 100,
                                    height: 100,
                                    fit: BoxFit.fill,
                                  ))
                              .toList(),
                        ),
                      )
                    ],
                  ),
                ),
                Container(
                  padding: const EdgeInsets.only(
                      top: 20, left: 15, right: 10, bottom: 15),
                  child: Column(
                    children: [
                      Container(
                        alignment: Alignment.centerLeft,
                        child: Text.rich(
                          TextSpan(
                            children: [
                              TextSpan(
                                text: '配送：',
                                style: StylesUtils.customTextStyle(
                                  color: ColorsUtils.color7979,
                                  fontSize: StylesUtils.fontSize13,
                                ),
                              ),
                              for (var i = 0; i < 3; i++)
                                WidgetSpan(
                                    child: Icon(
                                      CupertinoIcons.star_fill,
                                      size: 15,
                                      color: HexColor(ColorsUtils.colorFe46),
                                    ),
                                    alignment: PlaceholderAlignment.middle),
                              WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.star_fill,
                                    size: 15,
                                    color: HexColor(ColorsUtils.colorCccc),
                                  ),
                                  alignment: PlaceholderAlignment.middle),
                            ],
                          ),
                        ),
                      ),
                      Container(
                        margin: const EdgeInsets.only(top: 10),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          '有点慢了，但是大风大雨的，送餐速度还能准时，辛苦外卖小哥哥了。',
                          style: StylesUtils.customTextStyle(
                            color: ColorsUtils.color0000,
                            fontSize: StylesUtils.fontSize13,
                            lineHeight: 1.5,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
